home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Periodicals / CSMP / C.S.M.P. Digest, Issue 3.031 < prev    next >
Internet Message Format  |  1994-06-09  |  55KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-031
  3. Date: Fri, 27 May 94 14:27:48 MET DST
  4.  
  5. C.S.M.P. Digest             Fri, 27 May 94       Volume 3 : Issue 31
  6.  
  7. Today's Topics:
  8.  
  9.         Any good Mac C books?
  10.         Basic, basic windows & PICT drawing
  11.         Help: Palette translation in CopyBits
  12.         How do I draw masked icons w-System 6?
  13.         Motorola announces Power Mac compilers
  14.         Polling the Serial Port
  15.  
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  19. (pottier@clipper.ens.fr).
  20.  
  21. The digest is a collection of article threads from the internet newsgroup
  22. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  23. regularly and want an archive of the discussions.  If you don't know what a
  24. newsgroup is, you probably don't have access to it.  Ask your systems
  25. administrator(s) for details.  If you don't have access to news, you may
  26. still be able to post messages to the group by using a mail server like
  27. anon.penet.fi (mail help@anon.penet.fi for more information).
  28.  
  29. Each issue of the digest contains one or more sets of articles (called
  30. threads), with each set corresponding to a 'discussion' of a particular
  31. subject.  The articles are not edited; all articles included in this digest
  32. are in their original posted form (as received by our news server at
  33. nef.ens.fr).  Article threads are not added to the digest until the last
  34. article added to the thread is at least two weeks old (this is to ensure that
  35. the thread is dead before adding it to the digest).  Article threads that
  36. consist of only one message are generally not included in the digest.
  37.  
  38. The digest is officially distributed by two means, by email and ftp.
  39.  
  40. If you want to receive the digest by mail, send email to listserv@ens.fr
  41. with no subject and one of the following commands as body:
  42.     help                        Sends you a summary of commands
  43.     subscribe csmp-digest Your Name    Adds you to the mailing list
  44.     signoff csmp-digest            Removes you from the list
  45. Once you have subscribed, you will automatically receive each new
  46. issue as it is created.
  47.  
  48. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  49. Questions related to the ftp site should be directed to
  50. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  51. digest are available there.
  52.  
  53. Also, the digests are available to WAIS users as comp.sys.mac.programmer.src.
  54.  
  55.  
  56. -------------------------------------------------------
  57.  
  58. >From ralcasid@tech.iupui.edu (Peter R Alcasid)
  59. Subject: Any good Mac C books?
  60. Date: Fri, 29 Apr 1994 16:37:47 GMT
  61. Organization: Purdue University School of Engineering & Technology at Indianapolis,IN
  62.  
  63. I'm intrested in programming the Mac using Think C.  Does anyone know of any
  64. good books that gives a step by step tutorial on how to program the Macintosh
  65. (i.e. accessing the Toolbox using C).  I've got Inside Macintosh: Macintosh
  66. Toolbox Essentials but everything is in PASCAL!  Any suggestions would be
  67. appretiated.
  68.  
  69. Ron Alcasid
  70.  
  71. +++++++++++++++++++++++++++
  72.  
  73. >From jtbell@presby.edu (Jon Bell)
  74. Date: Sat, 30 Apr 1994 11:05:08 GMT
  75. Organization: Presbyterian College, Clinton, South Carolina USA
  76.  
  77. In article <Cp14uz.K7y@iupui.edu>,
  78. Peter R Alcasid <ralcasid@tech.iupui.edu> wrote:
  79. >I'm intrested in programming the Mac using Think C.  Does anyone know of any
  80. >good books that gives a step by step tutorial on how to program the Macintosh
  81. >(i.e. accessing the Toolbox using C).  
  82.  
  83. "Macintosh C Programming Primer", by Dave Mark and Cartwright Reed,
  84. published by Addison-Wesley.  It's in two volumes.
  85.  
  86. -- 
  87. Jon Bell <jtbell@presby.edu>                        Presbyterian College
  88. Dept. of Physics and Computer Science        Clinton, South Carolina USA
  89.  
  90. +++++++++++++++++++++++++++
  91.  
  92. >From rfblec@sunfish.usd.edu (Bob "Skippy" Blechinger)
  93. Date: Wed, 4 May 1994 10:31:01 GMT
  94. Organization: University of South Dakota
  95.  
  96. ralcasid@tech.iupui.edu (Peter R Alcasid) writes:
  97.  
  98. >I'm intrested in programming the Mac using Think C.  Does anyone know of any
  99. >good books that gives a step by step tutorial on how to program the Macintosh
  100. >(i.e. accessing the Toolbox using C).  I've got Inside Macintosh: Macintosh
  101. >Toolbox Essentials but everything is in PASCAL!  Any suggestions would be
  102. >appretiated.
  103.  
  104. >Ron Alcasid
  105.  
  106. Ron,
  107.   Try "Learn C on the Macintosh" by Dave Mark; it comes with a "lite" 
  108. version of Think C, *and* it comes with an upgrade offer to the *full*
  109. Think C for only $129 (this might have changed since I got mine, though)
  110.  
  111.   After that, you can step up to the "Macintosh C Programming Primer", by
  112. Dave Mark & Cartwright Reed; it's a 2-volume set, and again, quite good...
  113.  
  114.   Hope this helps!
  115.  
  116.   -Bob Blechinger
  117.     AppleCore of Siouxland
  118.       Mac Software Director
  119.         Sioux Falls, South Dakota
  120.           rfblec@sunfish.usd.edu
  121.  
  122.  
  123. +++++++++++++++++++++++++++
  124.  
  125. >From dmoney@magnus.acs.ohio-state.edu (Dean R Money)
  126. Date: 4 May 1994 16:31:48 GMT
  127. Organization: The Ohio State University
  128.  
  129. Bob "Skippy" Blechinger <rfblec@sunfish.usd.edu> wrote:
  130. >ralcasid@tech.iupui.edu (Peter R Alcasid) writes:
  131. >>I'm intrested in programming the Mac using Think C.  Does anyone know of any
  132. >>good books that gives a step by step tutorial on how to program the Macintosh
  133. >>(i.e. accessing the Toolbox using C).  I've got Inside Macintosh: Macintosh
  134. >>Toolbox Essentials but everything is in PASCAL!  Any suggestions would be
  135. >>appretiated.
  136. >
  137. >  Try "Learn C on the Macintosh" by Dave Mark; it comes with a "lite" 
  138. >version of Think C, *and* it comes with an upgrade offer to the *full*
  139. >Think C for only $129 (this might have changed since I got mine, though)
  140. >
  141. >  After that, you can step up to the "Macintosh C Programming Primer", by
  142. >Dave Mark & Cartwright Reed; it's a 2-volume set, and again, quite good...
  143.  
  144. I would agree.  Those three books, along with Inside Mac I, II, V, and VI,
  145. not only got me started in programming on the Mac, but helped me learn
  146. C from scratch.  I did know Pascal before, though, so it wasn't difficult
  147. for me to understand the Pascal examples in IM, and make Toolbox calls
  148. in C.
  149.  
  150. Dean. 
  151.  
  152. +++++++++++++++++++++++++++
  153.  
  154. >From susanlesch@aol.com (SusanLesch)
  155. Date: 4 May 1994 23:33:05 -0400
  156. Organization: America Online, Inc. (1-800-827-6364)
  157.  
  158.   In article <rfblec.768047461@sunfish>,
  159.   rfblec@sunfish.usd.edu (Bob "Skippy" Blechinger) writes:
  160.  
  161. > Try "Learn C on the Macintosh" by Dave Mark; it comes 
  162. > with a "lite" > version of Think C...
  163.  
  164.   Oh, dear, no.
  165.   
  166.   I would _not_ recommend "Learn C on the Macintosh" to
  167.   anyone seriously interested in learning the C language.
  168.   There is no formal definition of all data types, little
  169.   rigor, and a casual attitude that does not lend itself to
  170.   the difficulties of IM. I wish I could suggest an
  171.   alternative, but I must leave that to others.
  172.   
  173.   For examples, that are, sadly, fairly representative of
  174.   the book on the whole: "long" is never defined, mentioned
  175.   once. "continue" is not in the book. There is an
  176.   incomplete definition of the "if" statement, both in the
  177.   text and the appendix, leaving out the essential form "if
  178.   else"!
  179.   
  180.   I believe LCOM causes more harm than good.
  181.  
  182.  
  183. +++++++++++++++++++++++++++
  184.  
  185. >From susanlesch@aol.com (SusanLesch)
  186. Date: 5 May 1994 00:28:02 -0400
  187. Organization: America Online, Inc. (1-800-827-6364)
  188.  
  189.   Sorry, I believe in an earlier post I said "if else" is
  190.   not in "Learn C on the Macintosh". It is "else if" that's
  191.   missing. (We're having AOL problems and I can't retrieve
  192.   what I said.)
  193.   
  194.   While I have the book out, the cover blurb says, among
  195.   other things, "reference material, including glossary,
  196.   Standard Library functions, and a C syntax reference." If
  197.   that's C's syntax, we're all in trouble. For shame,
  198.   Addison-Wesley.
  199.  
  200. +++++++++++++++++++++++++++
  201.  
  202. >From ojtv@sun3.oulu.fi (Olli Vuolteenaho)
  203. Date: Fri, 6 May 1994 15:55:15 GMT
  204. Organization: University of Oulu, Department of Physiology
  205.  
  206. SusanLesch (susanlesch@aol.com) wrote:
  207. :   Sorry, I believe in an earlier post I said "if else" is
  208. :   not in "Learn C on the Macintosh". It is "else if" that's
  209. :   missing. (We're having AOL problems and I can't retrieve
  210. :   what I said.)
  211. :   
  212. :   While I have the book out, the cover blurb says, among
  213. :   other things, "reference material, including glossary,
  214. :   Standard Library functions, and a C syntax reference." If
  215. :   that's C's syntax, we're all in trouble. For shame,
  216. :   Addison-Wesley.
  217.  
  218. Sorry for my ignorance, but what kind of special definition
  219. would "else-if" need? It isn't specifically defined, for example,
  220. in Turbo C/C++ reference manual either, is it.
  221.  
  222. I don't have as pessimistic opinion about Learn C on the Macintosh
  223. as you do.
  224. If you have programming experience it feels awfully slow-paced, but
  225. then it wasn't written for you. I think that it presents the basics
  226. of C in an entertaining way, it might even encourage someone to explore
  227. programming deeper, unlike, for example, Lippman's C++ primer that I've
  228. often seen recommended as the first book on (C++) programming (it's 
  229. an excellent book for the more experienced, though). 
  230. And BTW, 'long' is explained on p. 207 of my LCOM.
  231.  
  232. Olli
  233.  
  234. +++++++++++++++++++++++++++
  235.  
  236. >From susanlesch@aol.com (SusanLesch)
  237. Date: 7 May 1994 00:48:07 -0400
  238. Organization: America Online, Inc. (1-800-827-6364)
  239.  
  240.   In article <1994May6.155515.10438@ousrvr.oulu.fi>,
  241.   ojtv@sun3.oulu.fi (Olli Vuolteenaho) writes: 
  242.  
  243. > what kind of special definition would "else-if" need?... 
  244.  
  245.   For a comparison, take the Waite Group's New C Primer
  246.   Plus. There are three forms described for the if
  247.   statement: if, if-else, and if-else if-else. Lacking
  248.   else-if, a newbie (like me :-) might wind up with nested
  249.   if's, sort of like wasting time with case statements. 
  250.  
  251. > [Learn C on the Macintosh] presents the basics of C in an
  252. > entertaining way, it might even encourage someone to
  253. > explore programming deeper 
  254.  
  255.   Sure, entertainment is part of education. But if
  256.   substance is forfeited in exchange, I am worried. Perhaps
  257.   if the book were titled "Learn C Basics on the
  258.   Macintosh", I wouldn't object so much. It's the reader
  259.   being led to think this is comprehensive C that offends
  260.   me. I'd also like to be taught good habits and structure.
  261.  
  262.   On another tack, take the first incarnation of HyperCard,
  263.   which was presented in an equally "entertaining way" and
  264.   could "encourage" someone to "explore programming
  265.   deeper". The problem here is similar. An informal
  266.   definition of a language, perhaps encouraging
  267.   lackadaisical programming practices, without mention of
  268.   error-checking is _lots_ of fun! 
  269.  
  270. > And BTW, 'long' is explained on p. 207 of my LCOM. 
  271.  
  272.   Yes, in passing, in the middle of an exercise on dice
  273.   rolling, in a chapter titled "Variable Data Types" that
  274.   doesn't define them. Where is the formal presentation of
  275.   data types? Again using New C Primer Plus as a
  276.   comparison, long, int, char, unsigned, float, and double
  277.   are neatly presented in one chapter (3).
  278.  
  279.   Thank you for responding, by the way. Mr. Mark's books
  280.   are extremely popular, and I would not expect many people
  281.   to agree with my assessment of Learn C on the Macintosh.
  282.  
  283. +++++++++++++++++++++++++++
  284.  
  285. >From nick@pitt.edu ( nick.c )
  286. Date: 7 May 94 20:55:24 GMT
  287. Organization: (none)
  288.  
  289. In Article <2q9pdh$1fj@search01.news.aol.com>, susanlesch@aol.com
  290. (SusanLesch) wrote:
  291.  
  292. >  I would _not_ recommend "Learn C on the Macintosh" to
  293. >  anyone seriously interested in learning the C language.
  294. >  There is no formal definition of all data types, little
  295. >  rigor, and a casual attitude that does not lend itself to
  296. >  the difficulties of IM.
  297.  
  298.     While I disagree with this assessment of _Learn_C_on_the
  299.   Macintosh_ (I'm reading the C++ version now, and find it quite
  300.   informative, as I found the C one), if you want rigor and 
  301.   less casual an aproach (and even if you don't) you should have
  302.   a copy of Kernigan and Ritchie.  This is probably stating the
  303.   obvious, but since it is the *definitive* work, you should have
  304.   a copy - no matter what you're doing with C.
  305.  
  306.  
  307.  
  308.    _/   _/  _/  _/_/_/   _/   _/  Sea Shells to C shells,  Waikiki to
  309.   _/_/ _/  _/  _/   _/  _/_/_/     the Internet, a wave, is a wave...
  310.  _/ _/_/  _/  _/       _/ _/
  311. _/   _/  _/   _/_/_/  _/   _/  CompSrv: 71232,766 I-Net: Nick@pitt.edu
  312.  
  313.  
  314. +++++++++++++++++++++++++++
  315.  
  316. >From thundero@news.delphi.com (THUNDERONE@DELPHI.COM)
  317. Date: 9 May 1994 04:07:27 -0000
  318. Organization: Delphi Internet Services Corporation
  319.  
  320. nick@pitt.edu ( nick.c ) writes:
  321.  
  322. >In Article <2q9pdh$1fj@search01.news.aol.com>, susanlesch@aol.com
  323. >(SusanLesch) wrote:
  324.  
  325. >>  I would _not_ recommend "Learn C on the Macintosh" to
  326. >>  anyone seriously interested in learning the C language.
  327. >>  There is no formal definition of all data types, little
  328. >>  rigor, and a casual attitude that does not lend itself to
  329. >>  the difficulties of IM.
  330.  
  331. >    While I disagree with this assessment of _Learn_C_on_the
  332. >  Macintosh_ (I'm reading the C++ version now, and find it quite
  333. >  informative, as I found the C one), if you want rigor and 
  334. >  less casual an aproach (and even if you don't) you should have
  335. >  a copy of Kernigan and Ritchie.  This is probably stating the
  336. >  obvious, but since it is the *definitive* work, you should have
  337. >  a copy - no matter what you're doing with C.
  338.  
  339. If you're learning C++ from Learn C++ on the Macintosh, you're going 
  340. to have serious problems using C++ for any medium to large-sized 
  341. project.  I agree with Susan on "Learn C.."- I know of no one who has 
  342. actually learned good C programming from it.  There are *good* C (and 
  343. C++) books out there.  They usually assume you have a PC or Unix, but 
  344. so does "Learn C on the Macintosh" (printf and fopen are not Macintosh 
  345. calls, you see).  Get one of them instead.
  346.  
  347. You might find the C++ book "quite informative," but that doesn't 
  348. change the fact that it does not teach correct use of C++.  Among 
  349. other things, it does not mention virtual destructors once.  It says 
  350. that because constructors *never* return anything, one should not 
  351. allocate memory in them, and discusses a "two-stage" workaround for 
  352. this "problem." It does not teach proper inheritence theory.  A review 
  353. I read of the book in DDJ mentioned that the book would only be useful 
  354. as a doorstop.  I happen to agree.
  355.  
  356. Chris
  357.  
  358. +++++++++++++++++++++++++++
  359.  
  360. >From $stephan@sasb.byu.edu (Stephan Fassmann)
  361. Date: 9 May 1994 18:39:34 GMT
  362. Organization: Brigham Young University
  363.  
  364. In article <2qkctv$suu@news.delphi.com> thundero@news.delphi.com (THUNDERONE@DELPHI.COM) writes:
  365. >If you're learning C++ from Learn C++ on the Macintosh, you're going 
  366. >to have serious problems using C++ for any medium to large-sized 
  367. >project.  I agree with Susan on "Learn C.."- I know of no one who has 
  368. >actually learned good C programming from it.  There are *good* C (and 
  369. >C++) books out there.  They usually assume you have a PC or Unix, but 
  370. >so does "Learn C on the Macintosh" (printf and fopen are not Macintosh 
  371. >calls, you see).  Get one of them instead.
  372.  
  373.     How about a nice list, Because I would like to get some books on Mac 
  374. c/C++ programing.
  375.  
  376. Stephan Fassmann   InterNet: $stephan@sasb.byu.edu   GEnie: S.FASSMANN
  377. carpe diem                                                carpe noctem
  378.  
  379. +++++++++++++++++++++++++++
  380.  
  381. >From Joe_Cabrera@bmugbost.uu.holonet.net
  382. Date: Tue, 10 May 1994 02:41:47 EST
  383. Organization: BMUG Boston
  384.  
  385. >> I believe ["Learn C on the Macintosh" by Dave Mark] causes more harm than
  386. good.<<
  387.  
  388. Can you offer an alternative text to use, then? I'm also beginning to learn C
  389. and LCOM doesn't feel like a "serious" enough book to begin learning C from. I
  390. also have the Waite group's New C Primer Plus. Is that any better? (As you can
  391. see, since I'm just beginning, I'm more interested in learning C itself rather
  392. than how it applies directly to the Mac yet.)
  393. -BMUG Boston 617-721-5840, East Coast BBS of The World's Largest Mac User Group 
  394.  
  395. +++++++++++++++++++++++++++
  396.  
  397. >From susanlesch@aol.com (SusanLesch)
  398. Date: 10 May 1994 17:21:04 -0400
  399. Organization: America Online, Inc. (1-800-827-6364)
  400.  
  401.   In article
  402.   <1994May10.024147.694130@bmugbost.uu.holonet.net>,
  403.   Joe_Cabrera@bmugbost.uu.holonet.net writes: 
  404.  
  405.   >> I believe ["Learn C on the Macintosh" by Dave Mark]
  406.   causes more harm than good.<< (-SGL)
  407.  
  408. > I also have the Waite group's New C Primer Plus. Is that
  409. > any better? (-JC)
  410.  
  411.   Well, I am no expert, and am as interested in seeing the
  412.   names of some good books as anyone. I used "New C Primer
  413.   Plus" and loved it. The comparisons between K&R and ANSI
  414.   C are simply great. As the only caveat, I skimmed the PC
  415.   / Unix / DOS sections on command lines for the most part,
  416.   keeping in mind that the authors tried to be somewhat
  417.   Macintosh and THINK C aware. My vote says yes, by all
  418.   means, use it.
  419.   
  420.   "New C Primer Plus" is being used on America Online to
  421.   teach C right now in a cross-platform class in their
  422.   online Programmer U, if I'm not mistaken.
  423.  
  424.  
  425. +++++++++++++++++++++++++++
  426.  
  427. >From Chris Hanson <chanson@mtlookitthat.chi.il.us>
  428. Date: Wed, 11 May 94 06:50:50 -0600
  429. Organization: Green Dragon Creations, Inc.
  430.  
  431.  
  432. In article <$stephan.3540.0@sasb.byu.edu>, Stephan Fassmann writes:
  433.  
  434. > In article <2qkctv$suu@news.delphi.com> thundero@news.delphi.com 
  435. (THUNDERONE@DELPHI.COM) writes:
  436. > >If you're learning C++ from Learn C++ on the Macintosh, you're going 
  437.  
  438. > >to have serious problems using C++ for any medium to large-sized 
  439. > >project.  I agree with Susan on "Learn C.."- I know of no one who has 
  440.  
  441. > >actually learned good C programming from it.  There are *good* C (and 
  442.  
  443. > >C++) books out there.  They usually assume you have a PC or Unix, but 
  444.  
  445. > >so does "Learn C on the Macintosh" (printf and fopen are not 
  446. Macintosh 
  447. > >calls, you see).  Get one of them instead.
  448. >     How about a nice list, Because I would like to get some books on Mac 
  449.  
  450. > c/C++ programing.
  451. > Stephan Fassmann   InterNet: $stephan@sasb.byu.edu   GEnie: 
  452. S.FASSMANN
  453. > carpe diem                                                carpe 
  454. noctem
  455.  
  456. "Practical C Programming" from O'Reilly & Associates is one of the best 
  457. C books out there.  It assumes UNIX -- it is an O'Reilly book, after 
  458. all. :-)
  459.  
  460. TTFN,
  461. Chris
  462.  
  463. +++++++++++++++++++++++++++
  464.  
  465. >From kenlong@netcom.com (Ken Long)
  466. Date: Thu, 12 May 1994 01:11:39 GMT
  467. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  468.  
  469. I wouldn't recommend Dave Mark's "Learn C on the Mac" as a first Mac C 
  470. book.  Dan Parks Sydow (DanParks@aol.com) has put out two great beginner 
  471. and beginner/intermediate Mac C books.  They illustrate what they 
  472. discuss.  Get "Think THINK C!" first.  This will get you well into the 
  473. idea, concept and viewpoint of programming on a MAC (leave the DOS C 
  474. books alone for a while).  Once you get that, and get through it, get 
  475. Think C 5.0.4, since it's simplest and most available example source runs 
  476. on it without complication.  Also get at least old volume I and II of 
  477. Inside Mac (if you're low on funds.  If not, get all current IM volumes 
  478. available.
  479.  
  480. Read the IM on what you have already learned, so you can see what the 
  481. explanations connect with, anh how.  That way, when you read on something 
  482. you haven't learned, you'll be better able to make a connection. 
  483.  
  484. Once you've gotten into it you can kind of tell which way to go from 
  485. there.  I'd recommend Dan's second book - Macintosh Programming 
  486. Techniques - to drive in the foundation of what you'll need to go on.  
  487. Then get the Primer books and their disks (saves typing all that in - or 
  488. scan and OCR it).
  489.  
  490. Many other books are just example sourc and explanations with some new 
  491. (to the beginner) how-to.  If you want details on specifics, like ANSI C 
  492. stuff, get The C Programming Language (the "K&R" book).  The Think C 5.x 
  493. Standard Libraries manual is excellent, too.
  494.  
  495. But a major source of "how to program" is example source.  Download as 
  496. much as possible.  Example code that runs is a competent programmer 
  497. telling you HOW to do some aspect of programming.  "Competent" simply 
  498. means he or she wrote a program that runs.  It may not be optimumly 
  499. coded, but it does run.
  500.  
  501. "How do I write a Main Event Loop?"  I look at as many Main Event Loops 
  502. in as many example source projects as it takes to get the idea of how 
  503. they are done.  This shows differences, similarities and identities 
  504. among them, and I can spot how and where to put modifications in.
  505.  
  506. So, those two books, TC 5 (you can update later), New Inside Mac andas 
  507. much example C source as you can get.  Straight Think C source is the 
  508. vast majority of example source you'll find.  Not Pascal, not C++.  Go 
  509. with the flow.
  510.  
  511. -Ken-
  512.  
  513. ---------------------------
  514.  
  515. >From bsa3320@u.cc.utah.edu (Brandon Allen)
  516. Subject: Basic, basic windows & PICT drawing
  517. Date: 13 May 1994 14:13:59 -0600
  518. Organization: University Of Utah Computer Center
  519.  
  520.  
  521. Somebody posted, asking for simple code regarding windows and displaying
  522. PICT's.  I can't find the thread now, but here is a bit of code that may
  523. prove instructive.  I hope it's not TOO basic for you.  I'd be happy to
  524. answer any other questions (for which I have answers).  Just e-mail me, if
  525. you like.  I don't know it all, but I'll be glad to tell you what I do know.
  526.  
  527. ___________________________________________________________________________
  528. { Ok, I'm assuming that you know how to create }
  529. {WIND & PICT resources using ResEdit . }
  530. { The first thing you'll need to do is load the}
  531. { WIND data using the GetNewCWind call, }
  532. { this function will return a WindowPtr to }
  533. { the window you are creating.}
  534.  
  535. PROGRAM ShowAWindow;
  536.  
  537.  VAR
  538.   myWindow: WindowPtr;
  539. { A pointer to your window data }
  540.   windowID: Integer;
  541. { ID number of your WIND resource }
  542.   pictureID: Integer;
  543. { ID of your Pict resource }
  544.   myPicture: PicHandle;
  545. { Handle to the PICT }
  546.   myRect: Rect;
  547. { A rectangle that will enclose the PICT }
  548. { when it is drawn }
  549.  
  550. BEGIN
  551.  windowID := 666;
  552. { Or whatever number you choose as }
  553. { your resource ID }
  554.  
  555.  myWindow := GetNewCWindow(windowID, NIL, WindowPtr(-1));
  556.  
  557. { Now, the nil after the windowID tells }
  558. { the Mac to allocate some new memory for }
  559. { your window, rather than using some }
  560. { that you have already allocated for it. }
  561. { The WindowPtr(-1) tells the computer }
  562. { which window to display the new }
  563. { window BEHIND.  For instance if you }
  564. { wanted your new window to appear behind }
  565. { a window whose data was contained in a }
  566. { variable called frontWind, then you }
  567. { would use frontWind instead.  In this case }
  568. { we want this window to be the }
  569. { front-most window, so we send a }
  570. { WindowPtr that points to the value -1. }
  571. { This is a standard value that tells the }
  572. { computer not to display your window }
  573. { behind any other window. }
  574.  
  575.  SetPort(myWindow);
  576.  
  577. { Now that we have created and displayed }
  578. { our window where we want it, we }
  579. { designate it as the current graphics port. }
  580. { This means that any drawing you }
  581. { do in your program will occur in this window. }
  582.  
  583.  myPicture := GetPicture(pictureID);
  584.  
  585. { This call loads your PICT resource into memory }
  586.  
  587.  IF myPicture <> NIL THEN
  588.   BEGIN
  589.    myRect := myPicture^^.picFrame;
  590.    DrawPicture(myPicture, myRect)
  591.   END;
  592.  
  593. { This bit of code ensures that the previous call }
  594. { to GetPicture was successful.  If the PICT had }
  595. { not been loaded, myPicture would contain NIL. }
  596. { If it doesn't contain NIL, we'll go ahead and draw }
  597. { it into our window with the DrawPicture call. }
  598. { Obviously myPicture is the handle we just }
  599. { created with the GetPicture call.  myRect is }
  600. { the rectangle into which the picture will be }
  601. { drawn.  This Rect is in local coordinates for }
  602. { your window (0,0 corresponds to the upper }
  603. { left hand corner of your window, not of }
  604. { the screen).  If myRect is different from the }
  605. { size of your PICT, QuickDraw will resize it }
  606. { automatically.  Thus, the assignment of the }
  607. { PICT's Rect (myPicture^^.picFrame) to }
  608. { myRect keeps the PICT at its original size. }
  609.  
  610.  
  611. { The rest of your program here ... }
  612.  
  613. END.
  614.  
  615. ---------------------------
  616.  
  617. >From jonbl@microsoft.com (Jon Blossom)
  618. Subject: Help: Palette translation in CopyBits
  619. Date: Tue, 3 May 1994 01:14:07 GMT
  620. Organization: Microsoft Corporation
  621.  
  622. I'm trying to create an off-screen GWorld whose palette
  623. matches the palette of the window I'm copying to.
  624.  
  625. What happens is that I set up a palette, say entry 3
  626. is red, and set it up for both the GWorld and the window.
  627. Then I poke a 3 somewhere into the GWorld memory, but
  628. when I call CopyBits(), the color's been translated to something
  629. else.
  630.  
  631. If I do a PmForeColor(3) then poke the result of a GetForeColor(),
  632. I get the correct results.
  633.  
  634. Somewhere, QuickDraw is remapping colors.
  635.  
  636. Anyone know how to prevent QuickDraw from remapping so that I
  637. have an identity relationship between the color table in my
  638. off-screen GWorld and the palette in my window? I don't
  639. want to have to go through this cheesy translation step!
  640.  
  641. Thanks
  642.  
  643. -Jon Blossom
  644. jonbl@microsoft.com
  645.  
  646. +++++++++++++++++++++++++++
  647.  
  648. >From u9119523@sys.uea.ac.uk (Graham Cox)
  649. Date: Fri, 6 May 1994 16:33:02 GMT
  650. Organization: School of Information Systems, UEA, Norwich
  651.  
  652. In article <Cp7CrM.CyF@microsoft.com>, jonbl@microsoft.com (Jon Blossom)
  653. wrote:
  654.  
  655. > I'm trying to create an off-screen GWorld whose palette
  656. > matches the palette of the window I'm copying to.
  657. > What happens is that I set up a palette, say entry 3
  658. > is red, and set it up for both the GWorld and the window.
  659. > Then I poke a 3 somewhere into the GWorld memory, but
  660. > when I call CopyBits(), the color's been translated to something
  661. > else.
  662. > If I do a PmForeColor(3) then poke the result of a GetForeColor(),
  663. > I get the correct results.
  664. > Somewhere, QuickDraw is remapping colors.
  665. > Anyone know how to prevent QuickDraw from remapping so that I
  666. > have an identity relationship between the color table in my
  667. > off-screen GWorld and the palette in my window? I don't
  668. > want to have to go through this cheesy translation step!
  669. > Thanks
  670. > -Jon Blossom
  671. > jonbl@microsoft.com
  672.  
  673.  
  674. Gosh, someone at Microsoft asking how to do things properly! Whatever next!
  675.  
  676. I suppose I should be nice and try and help, though actually I don't know
  677. the exact answer. However, it is definitely documented in Inside Mac VI in
  678. the Palette Manager chapter. You have to set up your GWorld colour table to
  679. the be the same as the window's colour table, then build a palette for the
  680. window which uses Animated Colours. Then you can draw using indexed values.
  681.  
  682. However, do you NEED to do this? (examine the problem carefully). Normally
  683. you should be working with RGB Colours, and drawing using QuickDraw into
  684. the GWorld- life will be easy if you do it this way, and don't try to draw
  685. with indexes. Of course, there are times when you might legitimately want
  686. to do this, but as I don't know what the problem is in this case, then it's
  687. hard to be sure.
  688.  
  689. One thing I do know is- NEVER,NEVER,NEVER poke indexes into the pixel image
  690. directly- this is a sure fire way of making a program incompatible with the
  691. video device. If QuickDraw doesn't know about the contents of an image
  692. (because you bypassed it) you will almost certainly not end up with what
  693. you want.
  694.  
  695. Please do it right- I know we all love to hate MS products on the Mac, but
  696. they COULD be really good if more people like you asked questions!!!
  697.  
  698. - ------------------------------------------------------------------------
  699. Graham
  700.  
  701. -Everyone is entitled to their opinion, no matter how wrong they may be...
  702. - ------------------------------------------------------------------------
  703.  
  704. +++++++++++++++++++++++++++
  705.  
  706. >From 103t_english@west.cscwc.pima.edu
  707. Date: 7 May 94 10:59:55 MST
  708. Organization: (none)
  709.  
  710. In article <u9119523-060594163303@cmpacc2.sys.uea.ac.uk>, u9119523@sys.uea.ac.uk (Graham Cox) writes:
  711. > In article <Cp7CrM.CyF@microsoft.com>, jonbl@microsoft.com (Jon Blossom)
  712. > wrote:
  713. >> I'm trying to create an off-screen GWorld whose palette
  714. >> matches the palette of the window I'm copying to.
  715. >> 
  716. >> What happens is that I set up a palette, say entry 3
  717. >> is red, and set it up for both the GWorld and the window.
  718. >> Then I poke a 3 somewhere into the GWorld memory, but
  719. >> when I call CopyBits(), the color's been translated to something
  720. >> else.
  721. >> 
  722. >> If I do a PmForeColor(3) then poke the result of a GetForeColor(),
  723. >> I get the correct results.
  724. >> 
  725. >> Somewhere, QuickDraw is remapping colors.
  726. >> 
  727. >> Anyone know how to prevent QuickDraw from remapping so that I
  728. >> have an identity relationship between the color table in my
  729. >> off-screen GWorld and the palette in my window? I don't
  730. >> want to have to go through this cheesy translation step!
  731. >> 
  732. [snip]
  733.  
  734. > One thing I do know is- NEVER,NEVER,NEVER poke indexes into the pixel image
  735. > directly- this is a sure fire way of making a program incompatible with the
  736. > video device. If QuickDraw doesn't know about the contents of an image
  737. > (because you bypassed it) you will almost certainly not end up with what
  738. > you want.
  739.  
  740. What if you are trying to get a video-game to go as fast as possible?
  741. OBviously, QuickDraw is too slow for such purposes...
  742.  
  743. > --------------------------------------------------------------------------
  744. > Graham
  745. > -Everyone is entitled to their opinion, no matter how wrong they may be...
  746. > --------------------------------------------------------------------------
  747.  
  748. Lawson
  749.  
  750. +++++++++++++++++++++++++++
  751.  
  752. >From ltaylor@academic.csubak.edu (John Stiles)
  753. Date: 7 May 1994 22:19:15 GMT
  754. Organization: California State University, Bakersfield
  755.  
  756. >>> Anyone know how to prevent QuickDraw from remapping so that I
  757. >>> have an identity relationship between the color table in my
  758. >>> off-screen GWorld and the palette in my window? I don't
  759. >>> want to have to go through this cheesy translation step!
  760. >>> 
  761.     The same thing happened to me. The GWorld was assigned a clut, this
  762. clut was changed to a palette and was applied to a window. Still, CopyBits
  763. wanted to do colormapping. Great.
  764.     I did notice that the mapping was 0 to 0, 1 to 1, 2 to 2, ... 255 to
  765. 255--i.e., no change. (it had to be with the custom palette I was using!)
  766.     The only workable solution was to implement a cheap blitter. It worked
  767. and I got it running faster than CopyBits anyway. So, problem solved. Still,
  768. there should be a more acceptable solution.
  769.                                 *Stiles
  770.  
  771.  
  772. +++++++++++++++++++++++++++
  773.  
  774. >From hall_j@sat.mot.com (Joseph Hall)
  775. Date: Sun, 8 May 1994 23:40:17 GMT
  776. Organization: Motorola Inc., Satellite Communications
  777.  
  778. Seems it was 103t_english@west.cscwc.pima.edu who said:
  779. >What if you are trying to get a video-game to go as fast as possible?
  780. >OBviously, QuickDraw is too slow for such purposes...
  781.  
  782. Obviously, you have never used a properly-aligned CopyBits.
  783.  
  784. There is no need to draw directly into screen memory on the Mac.  Munge
  785. your bits in your favorite quickest, hairiest way offscreen and then use 
  786. QuickDraw to copy them onto the screen.
  787.  
  788. I'll grant that QuickDraw's line- and circle-drawing algorithms are
  789. both slow and a little weird, but you don't have to use *them* to draw
  790. into an offscreen area.
  791.  
  792. -- 
  793. Joseph Nathan Hall | Joseph's Law of Interface Design: Never give your users
  794. Software Architect | a choice between the easy way and the right way.
  795. Gorca Systems Inc. |                 joseph@joebloe.maple-shade.nj.us (home)
  796. (on assignment)    | (602) 732-2549 (work)  Joseph_Hall-SC052C@email.mot.com
  797.  
  798. +++++++++++++++++++++++++++
  799.  
  800. >From pottier@trimaran.ens.fr (Francois Pottier)
  801. Date: 9 May 1994 10:11:30 GMT
  802. Organization: Ecole Normale Superieure, PARIS, France
  803.  
  804. In article <2qh453$aag@nic-nac.csu.net>,
  805. John Stiles <ltaylor@academic.csubak.edu> wrote:
  806.  
  807. >    The same thing happened to me. The GWorld was assigned a clut, this
  808. >clut was changed to a palette and was applied to a window. Still, CopyBits
  809. >wanted to do colormapping. Great.
  810. >    I did notice that the mapping was 0 to 0, 1 to 1, 2 to 2, ... 255 to
  811. >255--i.e., no change. (it had to be with the custom palette I was using!)
  812. >    The only workable solution was to implement a cheap blitter. It worked
  813. >and I got it running faster than CopyBits anyway. So, problem solved. Still,
  814. >there should be a more acceptable solution.
  815.  
  816. There is one. Just replace the destination color table's ctSeed with
  817. the source table's one. This will let CopyBits know that the color tables
  818. are indeed equal, and no mapping will be performed. I think it is described
  819. in Inside Mac, but I don't know for sure, since Imaging hasn't appeared in
  820. French bookstores yet.
  821.  
  822.  
  823. -- 
  824. Francois Pottier                                            pottier@dmi.ens.fr
  825. - ----------------------------------------------------------------------------
  826. This area dedicated to the preservation of endangered species.         "Moof!"
  827.  
  828. +++++++++++++++++++++++++++
  829.  
  830. >From Phil Smy <psmy@io.org>
  831. Date: 10 May 1994 18:42:26 GMT
  832. Organization: Innotech MultiMedia Corp.
  833.  
  834. In article <2ql28i$1q4@nef.ens.fr> Francois Pottier,
  835. pottier@trimaran.ens.fr writes:
  836. >There is one. Just replace the destination color table's ctSeed with
  837. >the source table's one. This will let CopyBits know that the color tables
  838. >are indeed equal, and no mapping will be performed. I think it is
  839. described
  840. >in Inside Mac, but I don't know for sure, since Imaging hasn't appeared
  841. in
  842. >French bookstores yet.
  843.  
  844. Here's what I do to make a GWorld with matching palette:
  845.  
  846.         thePal = GetPalette(front->macPort);
  847.         if (thePal)
  848.         {
  849.             offColors = GetCTable(ktheCLUT);
  850.             Palette2CTab(thePal,offColors);
  851.         }
  852.  
  853.         GetGWorld(&savePort,&saveDevice);
  854.  
  855.         depth = (*(*saveDevice)->gdPMap)->pixelSize;
  856.         depth = depth & 0x0000FFFF;
  857.  
  858.         error = NewGWorld(&offPort, depth ,&borderRect,offColors,nil,0);
  859.         if (error != noErr)
  860.             // do something about this!
  861.  
  862.         SetGWorld(offPort,nil);
  863.  
  864. I have had no colour mapping problems doing this. I don't know if this
  865. helps.
  866.  
  867. Phil
  868. ******************************************************************
  869. * Phil Smy                    * Interactive CDRom MultiMedia     *
  870. * Sr. Developer               * #include <stddisclaimer.h>       *
  871. * Innotech MultiMedia Corp.   * Wot Gorilla?                     *
  872. ******************************************************************
  873.  
  874. +++++++++++++++++++++++++++
  875.  
  876. >From grobbins@apple.com (Grobbins)
  877. Date: 10 May 1994 19:56:42 -0700
  878. Organization: Skunkworks
  879.  
  880. In article <2qh453$aag@nic-nac.CSU.net>,
  881. John Stiles <ltaylor@academic.csubak.edu> wrote:
  882. >>>> Anyone know how to prevent QuickDraw from remapping so that I
  883. >>>> have an identity relationship between the color table in my
  884. >>>> off-screen GWorld and the palette in my window?
  885. >       The same thing happened to me. The GWorld was assigned a clut, this
  886. >clut was changed to a palette and was applied to a window. Still, CopyBits
  887. >wanted to do colormapping.
  888.  
  889. Did you try setting bit 14 of ctFlags?  Take a look at the
  890. palette manager article in issue 5 of develop and the ctSeed
  891. reference in the Palette Manager chapter of Inside Mac VI
  892. for a discussion of how to use that bit to avoid unintended
  893. color mappings.
  894.  
  895. Grobbins            grobbins@apple.com
  896.  
  897. Usual disclaimers apply.
  898.  
  899.  
  900. +++++++++++++++++++++++++++
  901.  
  902. >From tenglish@west.cscwc.pima.edu
  903. Date: 10 May 94 21:51:32 MST
  904. Organization: (none)
  905.  
  906. In article <1994May8.234017.25097@sat.mot.com>, hall_j@sat.mot.com (Joseph Hall) writes:
  907. > Seems it was 103t_english@west.cscwc.pima.edu who said:
  908. >>What if you are trying to get a video-game to go as fast as possible?
  909. >>OBviously, QuickDraw is too slow for such purposes...
  910. > Obviously, you have never used a properly-aligned CopyBits.
  911. > There is no need to draw directly into screen memory on the Mac.  Munge
  912. > your bits in your favorite quickest, hairiest way offscreen and then use 
  913. > QuickDraw to copy them onto the screen.
  914. > I'll grant that QuickDraw's line- and circle-drawing algorithms are
  915. > both slow and a little weird, but you don't have to use *them* to draw
  916. > into an offscreen area.
  917.  
  918. I'm sorry. From what you had said (as I dimly recall it), you seemed to be
  919. advocating the use of QuickDraw for *everything*.
  920.  
  921. Obviously, CopyBits is part of QUickDraw, but I was taking you to mean circles
  922. and so on as well...
  923.  
  924. Lawson (formerly 103T_English... The Sys Admin got her lines crossed and renamed
  925. my account with my brother's... imagine my surprise...)
  926.  
  927. +++++++++++++++++++++++++++
  928.  
  929. >From Mark Hanrek <hanrek@cts.com>
  930. Date: Wed, 11 May 1994 12:06:41 GMT
  931. Organization: The Information Workshop
  932.  
  933. In article <u9119523-060594163303@cmpacc2.sys.uea.ac.uk> Graham Cox,
  934. u9119523@sys.uea.ac.uk writes:
  935.  
  936. >> I'm trying to create an off-screen GWorld whose palette
  937. >> matches the palette of the window I'm copying to.
  938.  
  939. In addition to the suggestions regarding the ctSeed, try taking the
  940. following approach.
  941.  
  942. - -- Color Tables
  943.  
  944.  
  945. If you can, try to avoid thinking of "a palette of colors" because 
  946. this English expression ends up confusing us when working with the 
  947. Palette Manager, which is clearly from another planet. :)
  948.  
  949. Try an approach that has worked well for me, of working with 
  950. color tables at all times, until the very last minute.
  951.  
  952. Then, when you are ready to activate the colors you need, just before 
  953. drawing to the window, create a palette from your color table using 
  954. CTab2Palette.  E-Z.
  955.  
  956. If you are going to be drawing into a GWorld, have the color table with
  957. the colors you want already attached to the GWorld. It helps to
  958. have the color table supplied when you create the GWorld as well.
  959.  
  960. For example, say you want to read in and draw a GIF picture....
  961.  
  962.   - Read in the GIF data, and extract the color table and picture rect.
  963.   - Create a color table with the picture's colors in it.
  964.   - Create a GWorld of the proper rect and supply the color table, too.
  965.   - While decoding the GIF's pixels, write the values directly into the  
  966.       GWorld's pixels, after having locked it down, natch.
  967.   - Create a palette from the color table using CTab2Palette.
  968.   - Activate the colors using NSetPalette and ActivatePalette
  969.   - Copybits from the GWorld to the window.
  970.  
  971. Also, observe the unwritten rules of always doing...
  972.  
  973.         ForeColor( blackColor );
  974.         BackColor( whiteColor );
  975.  
  976. before performing a CopyBits.
  977.  
  978. - --- Palettes
  979.  
  980. Also, it is good to be up on what the Palette Manager is doing.
  981.  
  982. There is an informative article in the March '93  d e v e l o p  called
  983. "The Palette Manager Way" in the Graphical Truffles column.
  984.  
  985. It describes how one can use the pmTolerant + pmExplicit usage modes
  986. to ensure that the positions of your colors don't change when your
  987. palette is activated.
  988.  
  989. Keep in mind that when you activate your palette, the Palette Manager 
  990. is arbitrating your "request" with the needs of the rest of the windows.
  991.  
  992. If you must have the exact colors you specify, then always use the
  993. pmTolerant + pmExplicit mode when you are creating your color tables 
  994. and palettes.  
  995.  
  996. One thing that helped me get the hang of things was always creating
  997. palettes and color tables using  ( pmTolerant + pmExplicit ) in the
  998. appropriate parameter.
  999.  
  1000. Things will work as you expect because you are essentially "insisting"
  1001. that the Palette Manager give you exactly what you are asking for, and
  1002. leave things in the positions you have them in.
  1003.  
  1004. Once you get things working, then as a separate exercise you can 
  1005. relax your color needs and experiment with the usage modes, if by
  1006. some freak accident of nature you actually have some extra time.  :)
  1007.  
  1008. Hope this helps.
  1009.  
  1010. Mark Hanrek
  1011.  
  1012. +++++++++++++++++++++++++++
  1013.  
  1014. >From jonbl@microsoft.com (Jon Blossom)
  1015. Date: Thu, 12 May 1994 02:59:06 GMT
  1016. Organization: Microsoft Corporation
  1017.  
  1018. >> One thing I do know is- NEVER,NEVER,NEVER poke indexes into the pixel image
  1019. >> directly- this is a sure fire way of making a program incompatible with the
  1020. >> video device. If QuickDraw doesn't know about the contents of an image
  1021. >> (because you bypassed it) you will almost certainly not end up with what
  1022. >> you want.
  1023. >
  1024. >What if you are trying to get a video-game to go as fast as possible?
  1025. >OBviously, QuickDraw is too slow for such purposes...
  1026.  
  1027. Which is basically exactly what I'm trying to do.
  1028.  
  1029. For certain applications, QuickDraw just isn't fast enough. For instance, my
  1030. polygon fills beat QD by about 25% or more because I know exactly how I want
  1031. to draw them.
  1032.  
  1033. What I really want to do is build my image the way I want it then say
  1034. "QuickDraw, here is a picture. Put it on the screen as fast as you can."
  1035.  
  1036. Unfortunately, I know that it's NOT going as fast as it can because it's doing
  1037. this damn color translation along the way even though I know it doesn't have
  1038. to.
  1039.  
  1040. -Jon Blossom
  1041. jonbl@microsoft.com
  1042.  
  1043.  
  1044.  
  1045. ---------------------------
  1046.  
  1047. >From s010mes@discover.wright.edu (Moshe Segal)
  1048. Subject: How do I draw masked icons w-System 6?
  1049. Date: Tue, 10 May 1994 15:33:15 GMT
  1050. Organization: Wright State University, Dayton, OH 45435
  1051.  
  1052. Does anybody know how to accomplish the following task: Display an ICN#
  1053. resource in a window using System 6. You may recall that almost all of
  1054. the icon utilities are only available on System 7, while the commands like
  1055. "GetIcon" only display ICON resources, which have no mask and leave an
  1056. unsightly white square around them when displayed.
  1057.  
  1058. I know it must be possible to display ICN# resources on pre-System 7
  1059. platforms. Indeed, a game called "Icon Bounce" does this beautifully. At
  1060. first I thought that was done by storing the ICN# patterns and masks as
  1061. regions.  But, alas, I couldn't figure out to get a pointer or handle to
  1062. the bitmap fields of the icon.
  1063.  
  1064. Anyone know the answer or know where I could find it on the net or in a
  1065. book (I have only the new Inside MacIntoshes). Or, does anyone have the
  1066. source code for the aforementioned Icon Bounce game?  Please post the
  1067. response, as I am on a friends account. 
  1068.  
  1069. Michael E. Kotler
  1070.   
  1071.  
  1072.  
  1073.  
  1074. +++++++++++++++++++++++++++
  1075.  
  1076. >From Matt Slot <fprefect@engin.umich.edu>
  1077. Date: 10 May 1994 21:01:38 GMT
  1078. Organization: University of Michigan
  1079.  
  1080. Moshe Segal, s010mes@discover.wright.edu writes:
  1081.  
  1082. >Does anybody know how to accomplish the following task: Display an ICN#
  1083. >resource in a window using System 6. You may recall that almost all of
  1084. >the icon utilities are only available on System 7, while the commands like
  1085. >"GetIcon" only display ICON resources, which have no mask and leave an
  1086. >unsightly white square around them when displayed.
  1087.  
  1088. Here is a snippet I extracted from some Icon plotting tools that I wrote.
  1089. I found the technique in a TechNote (I think). It works for both System 6 
  1090. and System 7. 
  1091.  
  1092. This code is was snipped from a program I wrote and wrapped into a little
  1093. function... it should be ready for dropping into a program with no bugs.
  1094.  
  1095. Matt Slot
  1096. fprefect@engin.umich.edu
  1097.  
  1098. void PlotIconInAllSystems(short iconID, Boolean hilited, Rect *iconRect) {
  1099.     BitMap iconMap;
  1100.     Handle iconHdl;
  1101.     
  1102.     if (!hasSys7 || PlotIconID(&iconRect, 0, (hilited) ? ttSelected : 0, iconID)) {
  1103.         if (iconHdl = GetResource('ICN#', iconID)) {
  1104.             HLock(iconHdl);
  1105.     
  1106.             iconMap.baseAddr = *iconHdl;
  1107.             iconMap.rowBytes = 4;
  1108.             SetRect(&iconMap.bounds,0,0,32,32);
  1109.             CopyBits(&iconMap, &thePort->portBits,
  1110.                     &iconMap.bounds, &iconRect, srcCopy, 0);
  1111.             
  1112.             if (hilited) {        
  1113.                 iconMap.baseAddr += 128;
  1114.                 CopyBits(&iconMap, &thePort->portBits,
  1115.                         &iconMap.bounds, &iconRect, srcXor, 0);
  1116.                 }
  1117.                 
  1118.             HUnlock(iconHdl);
  1119.             ReleaseResource(iconHdl);
  1120.             }
  1121.           else FrameRect(&iconRect);    // Something went wrong -- wimp out
  1122.         }
  1123.     }
  1124.  
  1125. +++++++++++++++++++++++++++
  1126.  
  1127. >From Richard Knuckey <richard@purplex.nacjack.gen.nz>
  1128. Date: Fri, 13 May 94 20:15:37 +1200
  1129. Organization: Purple X's Humble Macintosh
  1130.  
  1131.  
  1132. The following mimics all of the system 7 icon drawing styes (in black and 
  1133. white only) It is cut from a larger and more complete icon handling unit.
  1134.  
  1135. const
  1136.   largeRowBytes = 4;
  1137.   smallRowBytes = 2;
  1138.   miniRowBytes = 2;
  1139.  
  1140.   largeMaskOffset = largeIconSize * largeRowBytes;
  1141.   smallMaskOffset = smallIconSize * smallRowBytes;
  1142.   miniMaskOffset = miniIconSize * miniRowBytes;
  1143.  
  1144. type
  1145.   IconListHandle = ^IconListPtr;
  1146.   IconListPtr = ^IconListType;
  1147.   IconListType = record
  1148.     icon: packed array[1..32] of longint;
  1149.     mask: packed array[1..32] of longint;
  1150.   end;
  1151.  
  1152.  
  1153. procedure DrawIconList (iconBounds: Rect; iconSize, transform: integer;     
  1154.                         iconData: univ Handle);
  1155. var
  1156.   iconBitMap, maskBitMap: BitMap;
  1157.   iconDisabled, iconOffLine, iconOpen, iconSelected: Boolean;
  1158.   copyMode, iconTransform: integer;
  1159.   drawPort: GrafPtr;
  1160.  
  1161. begin
  1162.   GetPort(drawPort);
  1163.   HLock(iconData);
  1164.  
  1165.   with iconBitMap do
  1166.     begin
  1167.       baseAddr := iconData^;
  1168.       bounds := iconBounds;
  1169.       maskBitMap := iconBitMap;
  1170.  
  1171.       case iconSize of
  1172.         largeIconSize: 
  1173.           begin
  1174.             rowBytes := largeRowBytes;
  1175.             maskBitMap.rowBytes := largeRowBytes;
  1176.             maskBitMap.baseAddr := Ptr(ord4(baseAddr) + largeMaskOffset);
  1177.           end;
  1178.  
  1179.         smallIconSize: 
  1180.           begin
  1181.             rowBytes := smallRowBytes;
  1182.             maskBitMap.rowBytes := smallRowBytes;
  1183.             maskBitMap.baseAddr := Ptr(ord4(baseAddr) + smallMaskOffset);
  1184.           end;
  1185.  
  1186.         miniIconSize: 
  1187.           begin
  1188.             rowBytes := miniRowBytes;
  1189.             maskBitMap.rowBytes := miniRowBytes;
  1190.             maskBitMap.baseAddr := Ptr(ord4(baseAddr) + miniMaskOffset);
  1191.           end;
  1192.  
  1193.         otherwise
  1194.           begin
  1195.             HUnlock(iconData);
  1196.             exit(DrawIconList);
  1197.           end;
  1198.       end;
  1199.     end;
  1200.  
  1201.   {the transform type is in the lower nibble}
  1202.   iconTransform := BAND(transform, $000F); 
  1203.   iconDisabled := iconTransform = ttDisabled;
  1204.   iconOffline := iconTransform = ttOffline;
  1205.   iconOpen := iconTransform = ttOpen;
  1206.   iconSelected := BAND(transform, ttSelected) <> 0;
  1207.  
  1208.   if iconOffline | iconOpen then
  1209.     begin
  1210.       PenMode(patXor);
  1211.       if iconSelected then
  1212.         PenPat(dkGray)
  1213.       else
  1214.         PenPat(ltGray);
  1215.       PaintRect(iconBounds);
  1216.     end;
  1217.  
  1218.   if (not (iconOffline | iconOpen)) & iconSelected then
  1219.     copyMode := srcOr
  1220.   else
  1221.     copyMode := srcBic;
  1222.   CopyBits(maskBitmap, drawPort^.portBits, iconBounds, iconBounds,
  1223.            copyMode, nil);
  1224.  
  1225.   if iconDisabled then
  1226.     begin
  1227.       PenMode(patXor);
  1228.       PenPat(gray);
  1229.     end;
  1230.  
  1231.   if iconOpen | iconOffline | iconDisabled then
  1232.     PaintRect(iconBounds);
  1233.  
  1234.   if (not iconOpen) then
  1235.     begin
  1236.       if iconOffline then
  1237.         if iconSelected then
  1238.           copyMode := srcBic
  1239.         else
  1240.           copyMode := srcOr
  1241.       else if iconDisabled then
  1242.         copyMode := srcBic
  1243.       else
  1244.         copyMode := srcXor;
  1245.  
  1246.       CopyBits(iconBitmap, drawPort^.portBits, iconBounds, iconBounds,
  1247.                copyMode, nil)
  1248.     end;
  1249.  
  1250.   if iconDisabled then
  1251.     PaintRect(iconBounds);
  1252.  
  1253.   PenMode(patOr);
  1254.   PenPat(black);
  1255.  
  1256.   HUnlock(iconData);
  1257. end;
  1258.  
  1259.  
  1260. ---------------------------
  1261.  
  1262. >From julie@zoot.sps.mot.com (Julie Shipnes)
  1263. Subject: Motorola announces Power Mac compilers
  1264. Date: 12 May 1994 16:29:40 -0500
  1265. Organization: Motorola RISC Software, Austin, TX
  1266.  
  1267.  
  1268.  MOTOROLA ANNOUNCES HIGH-PERFORMANCE POWERPC MICROPROCESSOR 
  1269.              COMPILERS FOR POWER MACINTOSH
  1270.  
  1271.   AUSTIN, Texas, May 10  -- Motorola's RISC Microprocessor Division 
  1272. today announced plans to port its optimizing PowerPC microprocessor compilers 
  1273. to Apple's complete line of Power Macintosh computers.  The C, C++ and FORTRAN 
  1274. compilers will be fully compatible with Apple's Macintosh Programmers' 
  1275. Workshop (MPW) development environment and will enable developers 
  1276. to simultaneously optimize code for each member of the PowerPC family 
  1277. of microprocessors, including PowerPC 601(TM), PowerPC 603(TM), 
  1278. PowerPC 604(TM) and PowerPC 620(TM).
  1279.  
  1280.   "The ability to take full advantage of the PowerPC performance features of
  1281. each member of the PowerPC family is a critical aspect of Motorola's
  1282. commitment to provide a complete solution for our customers," said Les
  1283. Crudele, vice president and general manager, Motorola RISC Microprocessor
  1284. Division.  "Our compilers will permit developers to leverage the performance
  1285. potential of current and future PowerPC microprocessors without the need to
  1286. recompile applications."
  1287.  
  1288.   The compilers, which are currently being tested within Apple and at select
  1289. beta sites, have demonstrated significant performance improvements for
  1290. critical applications.  Much of the performance increase is because the
  1291. Motorola compilers optimize code to take advantage of individual features of
  1292. the superscalar PowerPC microprocessors, while still maintaining code
  1293. compatibility across all PowerPC architecture family members.
  1294.  
  1295.   The compilers can be configured to optimize code for a particular chip
  1296. implementation, or they can generate a series of objects that target
  1297. multiple PowerPC microprocessor.  As a result, developers can develop
  1298. applications now that will be optimally configured for existing and future
  1299. Apple systems.
  1300.  
  1301.   "By integrating their compiler development with the PowerPC chip design
  1302. efforts in Austin, Motorola is in a unique position to bring highly
  1303. optimizing compilers to market quickly for forthcoming PowerPC
  1304. microprocessors," said Peter Christy, senior director of developer products
  1305. engineering at Apple Computer, Inc. "The Motorola compilers complement the MPW 
  1306. compilers and tools already available from Apple and others, and provide 
  1307. Macintosh developers with a more complete set of options for creating 
  1308. high-performance applications for the exciting Power Macintosh platform."
  1309.  
  1310.   Motorola has also announced its intention to integrate its compilers into
  1311. the CodeWarrior development environment offered by Metrowerks, Inc. By
  1312. supporting both the MPW and CodeWarrior environments, users will be able to
  1313. leverage the performance advantages of the Motorola compilers without
  1314. needing to adopt a new development environment.
  1315.  
  1316.   "The addition of Motorola's compilers to the CodeWarrior environment will
  1317. offer an immediate performance boost for those CodeWarrier developers that
  1318. are working on leading-edge applications for future implementations of
  1319. PowerPC microprocessors," said Metrowerks president and CEO Greg Galanos.
  1320. According to Galanos, Metrowerks is defining a tools and language interface
  1321. for CodeWarrior that will permit developers to use standardized language
  1322. conventions and user interfaces for a variety of development tools.
  1323.  
  1324.   Motorola will accept orders in July 1994 for the MPW-based compilers and
  1325. tools running native on Power Macintosh and 68000-based Macintosh systems at
  1326. an initial list price of $349.  The company will offer a beta version of the
  1327. compiler for CodeWarrior in late 1994.  For additional information,
  1328. customers can call 800-845-MOTO.
  1329.  
  1330.   PowerPC microprocessors are based on reduced instruction set computing
  1331. (RISC) and incorporate leading edge technologies from IBM and Motorola.  The
  1332. family of PowerPC microprocessors is designed to address a wide range of
  1333. computing requirements, from portable and desktop computers to midrange
  1334. workstations and servers, to multi-processing, fault-tolerant and
  1335. supercomputing systems.  PowerPC microcontrollers also will be used for
  1336. embedded control applications in automotive and consumer products.
  1337.  
  1338.   Companies developing PowerPC systems and subsystems include Apple
  1339. Computer, Canon, DayStar Digital, Ford Motor Co., Groupe Bull, Harris,
  1340. Hitachi, IBM, ISG Technologies, Mercury Computer Systems, Motorola Computer
  1341. Group, Parsytec, PowerHouse, Scientific Atlanta, Shannon Computer, Tadpole
  1342. Technologies, the Taiwan New PC Consortium, THOMSON-CSF and YARC.
  1343.  
  1344.   Having 1993 worldwide sales of $5.7 billion, Motorola's Semiconductor
  1345. Products Sector is the largest U.S.-based broad line supplier of
  1346. semiconductors, with a balanced portfolio of more than 50,000 devices.
  1347. Motorola is one of the world's leading providers of wireless communications,
  1348. semiconductors, and advanced electronic systems and services.  Major
  1349. equipment businesses include cellular telephone, two-way radio, paging and
  1350. data communications, personal communications, automotive, defense and space
  1351. electronics and computers.  Communications devices, computers and millions
  1352. of consumer products are powered by Motorola semiconductors.  Motorola's
  1353. 1993 sales were $17 billion.
  1354.  
  1355.   NOTE: Product names are trademarks of their respective companies. PowerPC,
  1356. PowerPC architecture, PowerPC 601, PowerPC 603, PowerPC 604 and PowerPC 620
  1357. are trademarks of International Business Machines Corporation and are used
  1358. by Motorola under license from International Business Machines Corporation.
  1359.  
  1360. CONTACT: (reader/Inquiry response) Motorola, Inc. RISC Microprocessor 
  1361. Division, P.O.  Box 202558, Austin, Texas, 78720-9895, 1-800-845-MOTO
  1362.  
  1363.  
  1364.  
  1365. - -------------------------- Oakhill -------------------------------
  1366. Julie Shipnes                        Mike Phillip
  1367. julie@pets.sps.mot.com               phillip@pets.sps.mot.com     
  1368.  
  1369. Motorola RISC Compiler Development
  1370. - -------------------------------------------------------------------
  1371.  
  1372. ---------------------------
  1373.  
  1374. >From sjf@phantom.com (Simon Jensen_Fellows)
  1375. Subject: Polling the Serial Port
  1376. Date: 28 Apr 1994 21:27:18 GMT
  1377. Organization: [MindVox] / Phantom Access Technologies / (+1 800-MindVox)
  1378.  
  1379. Hi,
  1380. Anyone got any advice about running a background process that polls the 
  1381. serial port ?
  1382. I have tried posting a VBL routine, patching a trap and just running a
  1383. background application.
  1384.  
  1385. My main problem is that I seem to loose all my settings (Baud rate, 
  1386. parity etc) once I exit the routine back to the O/S.
  1387.  
  1388. I guess I`m doing something wrong: any advice or sample code ?
  1389.  
  1390. Thanking you in advance.
  1391.  
  1392. Simon.
  1393.  
  1394.  
  1395. +++++++++++++++++++++++++++
  1396.  
  1397. >From ctrfree@mr.net (Evan Olcott)
  1398. Date: 29 Apr 1994 22:50:13 GMT
  1399. Organization: Centor Freed Inc.
  1400.  
  1401. Best thing to do is to patch WaitNextEvent. Open the serial drivers
  1402. upon startup (a lovely piece of extension code) and hold them in an A4
  1403. global buffer. Upon each call to your patch, get the globals (to get
  1404. the refNum and other stuff) and check the port.
  1405. Seems to work for me. Now the tricky part is serial port arbitration...
  1406. ;-)
  1407.  
  1408. Evan Olcott, programmer
  1409. Centor Freed Inc.
  1410. 100 N. 6th Street #989C
  1411. Minneapolis, MN 55417
  1412. "There are no experimental failures. There's only more data." - Bryce
  1413.  
  1414. +++++++++++++++++++++++++++
  1415.  
  1416. >From oster@netcom.com (David Phillip Oster)
  1417. Date: Thu, 12 May 1994 19:59:24 GMT
  1418. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  1419.  
  1420.  
  1421. You'd have to be absolutely insane to poll the serial ports. Anybody in their
  1422. right mind would do a PBRead(&io, TRUE); i.e., an asynchronous read. The
  1423. operating system will call your completion routine at interrupt level when
  1424. the read completes: you never need to poll. Your completion routine can do
  1425. another read.  You may want to set up a deadman-switch VBL task: your
  1426. completion routine is expecting data in at most 10 seconds, so it sets up
  1427. a VBL task with a 15 second timeout. If the read completes, the completion
  1428. routine cancels the VBL and starts a fresh one. If something went wrong,
  1429. the VBL gives you back control so you can fix things (like re-enable the
  1430. serial ports, notify the user that something went wrong, etc.)
  1431.  
  1432. Back in '85 I used this technique to interface serial digitizing tablets
  1433.  
  1434. ---------------------------
  1435.  
  1436. End of C.S.M.P. Digest
  1437. **********************
  1438.  
  1439.  
  1440.  
  1441.